package com.gibs.peixunapi.utils;

import com.gibs.peixunapi.enums.ResultEnum;
import com.gibs.peixunapi.result.PageData;
import com.gibs.peixunapi.result.PageResult;
import com.gibs.peixunapi.result.Result;

/**
 * @author liangjiawei
 * @date 2020/08/20/11:26
 * @Version 1.0
 * @Description:
 */
public class ResultUtil {



    public static Result<Object> success(ResultEnum codeMsg) {
        return new Result(codeMsg.getCode(),codeMsg.getMsg(),null);
    }

    public static Result<Object> success(ResultEnum codeMsg, Object data) {
        return new Result(codeMsg.getCode(),codeMsg.getMsg(),data);
    }


    public static PageResult<Object> successPage(ResultEnum codeMsg) {
        return new PageResult(codeMsg.getCode(),codeMsg.getMsg());
    }
    public static PageResult<Object> successPage(ResultEnum codeMsg, PageData data) {
        return new PageResult(codeMsg.getCode(),codeMsg.getMsg(),data);
    }

    public static Result fail(ResultEnum failCodeMsg) {
        return new Result(failCodeMsg.getCode(), failCodeMsg.getMsg());
    }
    public static Result fail(ResultEnum failCodeMsg, Object data) {
        return new Result(failCodeMsg.getCode(), failCodeMsg.getMsg(),data);
    }

    public static Result error(Integer code, String msg) {
        return new Result(code, msg);
    }
    public static Result error(ResultEnum errorCodeMsg) {
        return new Result(errorCodeMsg.getCode(), errorCodeMsg.getMsg());
    }
    public static Result error(ResultEnum errorCodeMsg, Object data) {
        return new Result(errorCodeMsg.getCode(), errorCodeMsg.getMsg(),data);
    }

}
